using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Deepcode.Flux.Core.Systems.Security;
using Deepcode.Flux.Core.Systems.Registry;

public partial class Private_Config_Registry_menu : Deepcode.Flux.Core.UI.AdministrationModulePage
{
	#region Permission Code Override
	public override string RequiredPermissionCode { get { return "FluxRegistry"; } }
	#endregion
	#region Page Load Event
	/// <summary>
	/// Page Load event
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			TreeNode tn = new TreeNode("/");
			tn.Expanded = true;
			tn.Target = "ReportFrame";
			tn.NavigateUrl="report.aspx?RPath=-1";
			_tree.Nodes.Add( tn );
			Populate( tn.ChildNodes, -1 );
		}
	}
	#endregion
	#region Data Binding
	/// <summary>
	/// Gets the registry nodes from RegistryKeyID for the tree and adds them to target
	/// </summary>
	/// <param name="target"></param>
	/// <param name="RegistryKeyID"></param>
	private void Populate(TreeNodeCollection target, int RegistryKeyID)
	{
		target.Clear();

		RegistryDataManager rdm = new RegistryDataManager();
		foreach (RegistryDataNode node in rdm.GetChildrenFor(RegistryKeyID))
		{
			if (((FluxRegistryKeyType)node.KeyType) == FluxRegistryKeyType.NODEPATH)
			{
				TreeNode tn = new TreeNode(node.KeyName);
				Populate(tn.ChildNodes, node.PK_ID);
				tn.Expanded = false;
				tn.Target = "ReportFrame";
				tn.NavigateUrl = "report.aspx?RPath=" + node.PK_ID.ToString();
				target.Add(tn);
			}
		}
	}
	#endregion
}
